package com.xyp.audiodemo;

import androidx.annotation.NonNull;
import androidx.appcompat.app.AppCompatActivity;
import androidx.core.app.ActivityCompat;
import androidx.core.content.ContextCompat;
import androidx.core.content.PermissionChecker;
import androidx.core.graphics.ColorUtils;

import android.Manifest;
import android.content.Intent;
import android.content.pm.PackageManager;
import android.graphics.Color;
import android.media.AudioFormat;
import android.media.AudioRecord;
import android.media.MediaRecorder;
import android.os.Bundle;
import android.os.Handler;
import android.os.Message;
import android.util.Log;
import android.view.View;
import android.widget.Button;
import android.widget.LinearLayout;
import android.widget.TextView;

import com.xyp.audiodemo.activity.LineChartActivity2;
import com.xyp.audiodemo.activity.RecordActivity;
import com.xyp.audiodemo.activity.RecordActivity2;
import com.xyp.audiodemo.model.Sound;
import com.xyp.audiodemo.service.SoundAnalysisThread;
import com.xyp.audiodemo.util.CheckPermissionUtils;
import com.xyp.audiodemo.util.FFT;

import pub.devrel.easypermissions.AfterPermissionGranted;

public class MainActivity extends AppCompatActivity implements  View.OnClickListener {
    private static final String TAG = "MainLog";



    private Button record_btn;


    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
        initView();
    }

    private void initView() {
        record_btn = findViewById(R.id.btn_activity_record);

        findViewById(R.id.btn_activity_record2).setOnClickListener(this);


        findViewById(R.id.btn_activity_linechart2).setOnClickListener(this);

        record_btn.setOnClickListener(this);
    }


    @Override
    public void onClick(View v) {
        Intent intent = new Intent();

        switch (v.getId()){
            case R.id.btn_activity_record:
                intent.setClass(this, RecordActivity.class);
                break;

            case R.id.btn_activity_linechart2:
                intent.setClass(this, LineChartActivity2.class);
                break;

            case R.id.btn_activity_record2:
                intent.setClass(this, RecordActivity2.class);
                break;
        }

        startActivity(intent);
    }
}
